package cn.gson.springboot.controller;

import cn.gson.springboot.model.pojos.Product;
import cn.gson.springboot.model.pojos.ProductClassify;
import cn.gson.springboot.model.pojos.Qa;
import cn.gson.springboot.model.service.ProductClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.util.List;

@Controller
public class ProductClassifyController {
    @Autowired
    ProductClassifyService proClassifyService;

    @RequestMapping("/pro-classify-list")
    @ResponseBody
    public List<ProductClassify> proClassifyList(){
        List<ProductClassify> proClassifies = proClassifyService.selectAllProductClassify();
        return proClassifies;
    }

    @RequestMapping("/tree-classify-list")
    @ResponseBody
    public List<ProductClassify> treeClassify(){
        List<ProductClassify> proClassifies = proClassifyService.treeClassify();
        return proClassifies;
    }

    @RequestMapping("/pro-id")
    @ResponseBody
    public ProductClassify proClassifyList(Integer proId){
        ProductClassify product = proClassifyService.selectProductById(proId);
        return product;
    }

    @RequestMapping("/add-pro-classify")
    @ResponseBody
    public void addClassify(@RequestBody ProductClassify classify){
        proClassifyService.addClassify(classify);
    }

    @RequestMapping("/proclassify-deleteOne")
    @ResponseBody
    public void deleteOne(Integer proId) {
        proClassifyService.deleteOne(proId);
    }

}
